/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cse308.entities;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Aaron
 */
@Entity
@Table(catalog = "nchorn", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Studentsample.findAll", query = "SELECT s FROM Studentsample s"),
    @NamedQuery(name = "Studentsample.findByQuality", query = "SELECT s FROM Studentsample s WHERE s.quality = :quality"),
    @NamedQuery(name = "Studentsample.findByIdentifier", query = "SELECT s FROM Studentsample s WHERE s.identifier = :identifier")})
public class Studentsample implements Serializable {
    private static final long serialVersionUID = 1L;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 2)
    @Column(nullable = false, length = 2)
    private String quality;
    @Basic(optional = false)
    @NotNull
    @Lob
    @Column(nullable = false)
    private byte[] content;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(nullable = false, length = 20)
    private String identifier;
    @JoinColumn(name = "assignmentname", referencedColumnName = "name")
    @ManyToOne
    private Assignment assignmentname;

    public Studentsample() {
    }

    public Studentsample(String identifier) {
        this.identifier = identifier;
    }

    public Studentsample(String identifier, String quality, byte[] content) {
        this.identifier = identifier;
        this.quality = quality;
        this.content = content;
    }

    public String getQuality() {
        return quality;
    }

    public void setQuality(String quality) {
        this.quality = quality;
    }

    public byte[] getContent() {
        return content;
    }

    public void setContent(byte[] content) {
        this.content = content;
    }

    public String getIdentifier() {
        return identifier;
    }

    public void setIdentifier(String identifier) {
        this.identifier = identifier;
    }

    public Assignment getAssignmentname() {
        return assignmentname;
    }

    public void setAssignmentname(Assignment assignmentname) {
        this.assignmentname = assignmentname;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (identifier != null ? identifier.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Studentsample)) {
            return false;
        }
        Studentsample other = (Studentsample) object;
        if ((this.identifier == null && other.identifier != null) || (this.identifier != null && !this.identifier.equals(other.identifier))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "cse308.entities.Studentsample[ identifier=" + identifier + " ]";
    }
    
}
